package com.example.yiqiuser.service.impl;

import com.example.yiqiuser.dao.NewsDao;
import com.example.yiqiuser.entity.News;
import com.example.yiqiuser.service.NewsService;
import com.example.yiqiuser.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: Jyc
 * @classname: NewsServiceImpl
 * @date: 2023/3/31
 * @time: 15:05
 * @description:
 */
@Service
public class NewsServiceImpl implements NewsService {
    @Resource
    private NewsDao newsDao;


    @Override
    public PageInfo queryParams(Page<News> page) {
        PageHelper.startPage(page.getPageNo(),page.getPageSize());
        return new PageInfo<>(newsDao.queryByParams(page.getData()));
    }

    @Override
    public News queryById(int id) {
        return newsDao.queryById(id);
    }

    @Override
    public int adds(News news) {
        return newsDao.adds(news);
    }

    @Override
    public int delete(int id) {
        return newsDao.delete(id);
    }

    @Override
    public int update(News news) {
        return newsDao.update(news);
    }
}
